/**
 * token 相关操作
 */
const TokenKey = 'as-water-web-token';
import { set, get, remove } from './storage.js';

/**
 * @description 设置 token
 * @param {String} value token值
 */
const setToken = (value) => {
  const expire = 24 * 60 * 60 * 2 // 两天
  set(TokenKey, value, expire);
};

/**
 * @description 读取 token
 */
const getToken = () => {
  const value = get(TokenKey);
  if (value) setToken(value);
  return value;
};

/**
 * @description 清除 token
 */
const removeToken = () => {
  remove(TokenKey);
};

export { setToken, getToken, removeToken };
